package com.example.demo.common;

import lombok.Data;

@Data
public class Result<T> {
    private Integer code;
    private String message;
    private T data;
    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.message = msg;
        this.data = data;
    }
    public static <T> Result<T> success(T data) {
        return new Result<>(0,"success",data);
    }
    public static <T> Result<T> success() {
        return new Result<>(0,"success",null);
    }


    public static <T> Result<T> success(String msg,T data) {
        return new Result<>(0,msg,data);
    }

    public static <T> Result<T> fail(String msg) {
        return new Result<>(4002,msg,null);
    }
    public static <T> Result<T> fail() {
        return new Result<>(4005,"操作失败",null);
    }
    public static <T> Result<T> fail(Integer code,String msg) {
        return new Result<>(code,msg,null);
    }
}
